From 264e9c0ce11839b41859de1ef720b68374b6f850 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 27 Dec 2006 06:12:53 +0000 Subject: [PATCH] Fix a few problems with nested menus in comboboxes (#386694, Yevgen 2006-12-17 Matthias Clasen Fix a few problems with nested menus in comboboxes (#386694, Yevgen Muntyan) * gtk/gtkcombobox.c (gtk_combo_box_menu_fill_level): Always connect the activate callback. (gtk_combo_box_menu_item_activate): Do nothing if called on an item with a submenu. (gtk_combo_box_menu_row_deleted): Remove a submenu when it is empty. --- ChangeLog | 12 ++++++++++++ gtk/gtkcombobox.c | 30 +++++++++++++++++++++++++----- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5d9d29ce50..8e013fcfd8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2006-12-17 Matthias Clasen + + Fix a few problems with nested menus in comboboxes + (#386694, Yevgen Muntyan) + + * gtk/gtkcombobox.c (gtk_combo_box_menu_fill_level): Always + connect the activate callback. + (gtk_combo_box_menu_item_activate): Do nothing if called on + an item with a submenu. + (gtk_combo_box_menu_row_deleted): Remove a submenu when it + is empty. + 2006-12-26 Mariano Suárez-Alvarez * gtk/gtkfilechooserbuuton.[hc]: Add a file-set signal to the diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c index dfa61facdb..c9ab32293a 100644 --- a/gtk/gtkcombobox.c +++ b/gtk/gtkcombobox.c @@ -2749,10 +2749,9 @@ gtk_combo_box_menu_fill_level (GtkComboBox *combo_box, gtk_combo_box_menu_fill_level (combo_box, submenu, &iter); } - else - g_signal_connect (item, "activate", - G_CALLBACK (gtk_combo_box_menu_item_activate), - combo_box); + g_signal_connect (item, "activate", + G_CALLBACK (gtk_combo_box_menu_item_activate), + combo_box); } gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); @@ -2946,7 +2945,10 @@ gtk_combo_box_menu_item_activate (GtkWidget *item, path = gtk_cell_view_get_displayed_row (GTK_CELL_VIEW (cell_view)); if (gtk_tree_model_get_iter (combo_box->priv->model, &iter, path)) - gtk_combo_box_set_active_iter (combo_box, &iter); + { + if (gtk_menu_item_get_submenu (GTK_MENU_ITEM (item)) == NULL) + gtk_combo_box_set_active_iter (combo_box, &iter); + } gtk_tree_path_free (path); @@ -3269,6 +3271,24 @@ gtk_combo_box_menu_row_deleted (GtkTreeModel *model, item = find_menu_by_path (combo_box->priv->popup_widget, path, FALSE); menu = gtk_widget_get_parent (item); gtk_container_remove (GTK_CONTAINER (menu), item); + + if (gtk_tree_path_get_depth (path) > 1) + { + GtkTreePath *parent_path; + GtkTreeIter iter; + GtkWidget *parent; + + parent_path = gtk_tree_path_copy (path); + gtk_tree_path_up (parent_path); + gtk_tree_model_get_iter (model, &iter, parent_path); + + if (!gtk_tree_model_iter_has_child (model, &iter)) + { + parent = find_menu_by_path (combo_box->priv->popup_widget, + parent_path, FALSE); + gtk_menu_item_remove_submenu (GTK_MENU_ITEM (parent)); + } + } } static void -- 2.30.2